package com.youzi.mdtool.entity;

import java.util.Set;
import java.util.TreeSet;

/**
 * 目录结构
 */
public class Catalog implements Comparable<Catalog> {
	
	
	private int id;
	private String path;
	private String name;
	//是否展开
	private boolean spread;
	private String href;
	private Set<Catalog> children;
	private boolean isDir = false;
	
	public Catalog (){
		this.children = new TreeSet<>();
	}
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public boolean isSpread() {
		return spread;
	}

	public void setSpread(boolean spread) {
		this.spread = spread;
	}

	public String getHref() {
		return href;
	}

	public void setHref(String href) {
		this.href = href;
	}

	public Set<Catalog> getChildren() {
		return children;
	}

	public void setChildren(Set<Catalog> children) {
		this.children = children;
	}

	public boolean isDir() {
		return isDir;
	}

	public void setDir(boolean isDir) {
		this.isDir = isDir;
	}

	@Override
	public int compareTo(Catalog o) {
        if (!this.isDir && o.isDir){
            return 1;
        }
        if (this.isDir && !o.isDir){
            return -1;
        }
        return 1;
	}

	@Override
	public String toString() {
		return "Catalog [id=" + id + ", path=" + path + ", name=" + name + ", spread=" + spread + ", href=" + href
				+ ", children=" + children + ", isDir=" + isDir + "]";
	}
	
	
	
	
	
}
